package cn.wj.school.cloud.dto;

import lombok.Data;

import java.io.Serializable;

/**
 * @Author: yueding
 * @Description:
 * @Date: Created in 15:10 2018/5/17
 * @Modified By:
 * Copyright(c) cai-inc.com
 */
@Data
public class PrivilegeCheckDTO implements Serializable{
    private static final long serialVersionUID = 8808856899539299452L;
    private Boolean isPermit = Boolean.FALSE;
    private int accessType;
    private String error;
    private int errorType;

    public enum AccessType {
        ANONYMOUS(0, "匿名访问"),
        AUTHENTICATE(1, "认证访问"),
        AUTHORIZE(2, "授权访问");

        private final int value;
        private final String display;

        private AccessType(int number, String display) {
            this.value = number;
            this.display = display;
        }

        public int toNumber() {
            return this.value;
        }

        public String toName() {
            return this.display;
        }

        public int id() {
            return this.value;
        }

        @Override
        public String toString() {
            return String.valueOf(this.value);
        }
    }

     public enum ErrorType {
        OK(200, "权限检查通过"),
        UNAUTHENTICATED(401, "用户未认证"),
        UNAUTHORIZED(403, "用户未授权");

        private final int value;
        private final String display;

        private ErrorType(int number, String display) {
            this.value = number;
            this.display = display;
        }

        public int toNumber() {
            return this.value;
        }

        public String toName() {
            return this.display;
        }

        public int id() {
            return this.value;
        }

        @Override
        public String toString() {
            return String.valueOf(this.value);
        }
    }
}
